# 1/2 create b
git branch page_col #create a new branch named "page_col"
# 2/2 then switch to b
git checkout page_col
# or 1+2/2 CREATE + SWITCH BRANCHES
git checkout -b page_col Git branches
Caution
Web page construction in progress…
Branches
Create & checkout a branch
“checkout” means to change the branch you are currently working on (or switch to)
Switch to other branch
You can also use git switch other_branch which is more specific
git switch page_col
cat .git/HEAD # (confirms me I moved)Rename a (local) branch
It’s the -m parameter !
- you cannot rename a remote branch –> you delete it and re-upload it
# In currently checkedout
git branch -m better_name
# in different branch (non HEAD)
git switch master
git branch test_branch # fake one
git branch -a # it's there
git branch -m test_branch test_branch2
git branch -a # yep!Push upstream a local branch
- Create local branch
- Switch to local branch
-
git push –-set-upstreamcommand (the 1st time you push) - Thereafter
git push(all subsequent git push commands automatically move local branch changes up to the remote branch.)
# 1 Create local branch
# 2 switch to local branch
git switch page_col
# 3.a git push –set-upstream command (1st time)
git push --set-upstream origin page_col
# check
git branch -a # YAY!
# 3.b git push origin (nest times )
git push originRename a (remote) branch
You need to 1. Publish an existing local branch on remote git push -u origin local_branch 2. So you delete old one and push up a new one from local repository
Merge a git branch into master
- List All Git Branches
- Switch to Master
- Merge Branch into Master
- Push Changes (push the local changes to the remote repository so everyone working on the project can fetch the latest version.)
Tip
Since merging is a type of commit, it also requires a commit message. There are two ways to specify the commit message:
# 1. List
git branch
# 2. Switch
git checkout master
# 3. The merge creates a merge commit, bringing together
# lines of development while preserving the history of the source branch.
git merge -m "Prova di merge" page_col
# 4. Push the local changes to the remote repository
git push originSee differences b/w branches
git diff master..page_col '***.qmd'QGit Rebase
- take commits from a separat branch and replay (shift the change down to the tip of master) them at the end of another brabch
- integrate recent commits without merging
you never rebase a public branch, only a private one!
YT video on diff merge - rebase